package com.example.sonone.controller;


//import com.example.sonone.dao.CacheDao;
import com.alibaba.fastjson.JSON;
import com.example.sonone.pojo.Job;
import com.example.sonone.pojo.Stu;
import com.example.sonone.service.impl.SystemParamCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.*;

@RestController
@RequestMapping("cache")
public class CacheController {

/*
    @Autowired
    private CacheDao cacheDao;
*/


    @PostMapping("json")
    public Job json(@RequestBody Job job) {

        job.setStartTime(LocalDateTime.now());
        job.setEndTime(new Date());
        // fast date类型转化之后是时间错， LocalDateTime 是时间格式。
        // {"endTime":1662967458742,"id":1,"name":"zjq","startTime":"2022-09-12T15:24:18.741"}
        String s = JSON.toJSONString(job);
        System.out.println(s);
        return job;
    }


    @PostMapping("test1")
    public String test1() {
        return SystemParamCache.getInstance().getParamValue("AccessKeyId");
    }


    @PostMapping("test2")
    public String test2() {
        return SystemParamCache.getInstance().getParamValue("smsParam");
    }

    /**
     * 测试 若表中字段为 空， 返回给前台是否有字段
     */
/*    @PostMapping("getStu")
    public List<Stu> getStu() {
        return cacheDao.getStu();
    }*/


}
